<?php
defined('IN_SITE') or exit('Access Denied');
$submenu = array(
	array($LANG['all_comment'],'?module=setting&tab=5'),
	);
$menu = admin_menu($LANG['comment_content_manage'],$submenu);
require_once 'comment.class.php';
$comment = new comment();
$forward = $forward ? $forward : HTTP_REFERER;
$action = $action ? $action : 'manage';
$filearray = array('delete', 'manage', 'pass');
in_array($action,$filearray) or showmessage($LANG['illegal_action'],$referer);
switch ($action)
{
	case 'manage':
		$condition = array();
		
        if (!empty($userid)){
			$userid = intval($userid);
			$condition[] = " `userid` = '$userid' ";
		}
		if (isset($keyid))  		$condition[] = " `keyid` = '$keyid' ";
		
		if ($status == '0' || $status == '1'){
			$condition[] = " `status` = '$status' ";
		}
		if(isset($ip)) {
			$condition[] = " `ip` = '$ip'";
		}
        if($srchfrom){
			$time = TIME; 
			$timeid = TIME - $timeid*24*60*60; 
			$condition[] = " `addtime` >= '$timeid' AND `addtime` <= '$time'";
		}
		if(!empty($keywords)){
			$keywords = trim($keywords);
			$condition [] = " `username` LIKE '%$keywords%' OR `content` LIKE '%$keywords%' " ;
		}
		
		$pagesize	= $SETTING['pagesize'] ? $SETTING['pagesize'] : 20;
		$page		= isset($page) ? intval($page) : '1' ;
		
		$comments = $comment->get_list($condition, $page, $pagesize);
		$pages = $comments['pages'];
		include 'comment_manage.tpl.php';
	break;
	case 'pass':
		if( empty( $cid ) ){
			showmessage('请选择要删除的评论','?module=comment&file=comment&action=manage&status=0');
		}
		if ( isset($cid) && $comment->pass( $cid, $status) ) {
			showmessage($LANG['operation_success'], '?module=comment&file=comment&action=manage');
		}
		showmessage($LANG['operation_failure']);
	break;
	case 'delete':
		if( empty( $cid ) )
        {
			showmessage('请选择要删除的评论');
		}
		if ( $comment->drop($cid) )
        {
			showmessage($LANG['operation_success'], '?module=comment&file=comment&action=manage');
		}
        else
        {
			showmessage($LANG['operation_failure']);
		}
	break;
}
?>